<?php

namespace app\admin\service\setting;

use app\common\model\setting\Agreement;
use tmcore\base\BaseService;

class AgreementService extends BaseService
{
    /**
     * 编辑协议
     * @param array $params
     * @return bool
     */
    public static function edit(array $params) : bool
    {
        return Agreement::edit([
            'name' => $params['name'] ?? '',
            'content' => $params['content'] ?? '',
        ], $params['type'], 'type');
    }

    /**
     * 查看协议详情
     * @param $params
     * @return array
     */
    public static function detail($params) : array
    {
        return Agreement::where(['type' => $params['type']])->findOrEmpty()->toArray();
    }
}